home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / HyperStacks Folder / Samples from the CD / Fun / ¡Spiro! / °Spiro! / background_2777.txt < prev    next >
Text File  |  1989-03-02  |  10KB  |  408 lines

  1. -- background: 2777 from stack: in
  2. -- bmap block id: 2207
  3. -- flags: 0000
  4. -- background id: 0
  5. -- name: 
  6. ----- HyperTalk script -----
  7. -------------SPIRO!¬©   by andrew c stone   ------------
  8. -------------UUCP     stone@hydra.unm.edu   stone@sleepy.cs.unm.edu
  9.  
  10. on spiro
  11.   ------ get the specifications:
  12.   ------ have defaults for no-brainers
  13.  
  14.   put (the commandkey is down) into useSpecial
  15.  
  16.  
  17.   put validate(fld "myangle") into angle
  18.   if angle is empty then
  19.     put 121 into angle
  20.     put 121 into fld "myangle"
  21.   end if
  22.  
  23.   put validate(fld "mywidth") into lwidth
  24.   if lwidth is empty then
  25.     put 1 into lwidth
  26.     put 1 into fld "mywidth"
  27.   end if
  28.   set the linesize to lwidth
  29.  
  30.   put validate(fld "mystartL") into Length
  31.   if Length is empty then
  32.     put 4 into Length
  33.     put 4 into fld "mystartL"
  34.   end if
  35.  
  36.   put validate(fld "myendL") into endLength
  37.   if endLength is empty then
  38.     put 300 into endLength
  39.     put 300 into fld "myendL"
  40.   end if
  41.  
  42.   put validate(fld "myincrement") into increment
  43.   if increment is empty then
  44.     put 4 into increment
  45.     put 4 into fld "myincrement"
  46.   end if
  47.   --------------------------
  48.   --convert angle to theta :
  49.   put (pi*angle)/180 into angle
  50.   ---center the drawing:
  51.   put 217 into X
  52.   put 171 into Y
  53.   put angle into theta
  54.   choose line tool
  55.   if useSpecial then
  56.     specialSpiro X,Y,theta, Length,increment,endLength,angle
  57.   else
  58.     set the pattern to 1
  59.     repeat
  60.       set cursor to busy
  61.       put X + trunc(Length * cos(theta)) into newX
  62.       put Y + trunc(Length * sin(theta)) into newY
  63.       drag from X,Y to newX,newY
  64.       put newX into X
  65.       put newY into Y
  66.       put theta + angle into theta
  67.       add increment to Length
  68.       if Length > endLength then exit repeat
  69.     end repeat
  70.   end if
  71.   choose select tool
  72.   drag from 434,1 to 512,342
  73.   type numtochar(8)
  74.   choose browse tool
  75. end spiro
  76.  
  77. on specialSpiro  X,Y,theta,Length,increment,endLength,angle
  78.   set the pattern to 1
  79.   domenu "select all"
  80.   domenu "invert"
  81.   drag from 434,0 to 512,342
  82.   type numtochar(8)
  83.   choose line tool
  84.   repeat
  85.     set cursor to busy
  86.     put X + trunc(Length * cos(theta)) into newX
  87.     put Y + trunc(Length * sin(theta)) into newY
  88.     drag from X,Y to newX,newY with optionkey
  89.     put newX into X
  90.     put newY into Y
  91.     put theta + angle into theta
  92.     add increment to Length
  93.     if Length > endLength then exit repeat
  94.   end repeat
  95. end specialSpiro
  96.  
  97. function validate var  ---because we care
  98. put var into temp
  99. repeat with i = 1 to length of temp
  100.   if char i of temp is not in ".0123456789" then
  101.     answer "Bad Data: "&var&&" Now using defaults."
  102.     return empty
  103.   end if
  104. end repeat
  105. return temp
  106. end validate
  107.  
  108.  
  109.  
  110.  
  111. -- part 2 (field)
  112. -- low flags: 00
  113. -- high flags: 0002
  114. -- rect: left=434 top=47 right=67 bottom=512
  115. -- title width / last selected line: 0
  116. -- icon id / first selected line: 0 / 0
  117. -- text alignment: 1
  118. -- font id: 3
  119. -- text size: 14
  120. -- style flags: 256
  121. -- line height: 18
  122. -- part name: myangle
  123.  
  124.  
  125. -- part 3 (button)
  126. -- low flags: 00
  127. -- high flags: C002
  128. -- rect: left=434 top=29 right=49 bottom=512
  129. -- title width / last selected line: 0
  130. -- icon id / first selected line: 0 / 0
  131. -- text alignment: 1
  132. -- font id: 3
  133. -- text size: 12
  134. -- style flags: 256
  135. -- line height: 16
  136. -- part name: Angle
  137. ----- HyperTalk script -----
  138. on mousedown
  139.   put PopUpMenu("90;91;103;109;121;129;136;145;152;159;163;170,Other‚Ķ", 0, the mouseV , the mouseH - 20) into which
  140.   if which is 0 then exit mousedown
  141.  
  142.   if which  is 1 then
  143.     put "90" into fld myangle
  144.   else if which is 2 then
  145.     put "91" into fld myangle
  146.   else if which is 3 then
  147.     put "103" into fld myangle
  148.   else if which is 4 then
  149.     put "109" into fld myangle
  150.   else if which is 5 then
  151.     put "121" into fld myangle
  152.   else if which is 6 then
  153.     put "129" into fld myangle
  154.   else if which is 7 then
  155.     put "136" into fld myangle
  156.   else if which is 8 then
  157.     put "145" into fld myangle
  158.   else if which is 9 then
  159.     put "152" into fld myangle
  160.   else if which is 10 then
  161.     put "159" into fld myangle
  162.   else if which is 11 then
  163.     put "163" into fld myangle
  164.   else if which is 12 then
  165.     put "170" into fld myangle
  166.   else if which is 13 then
  167.     ask "Please enter angle between 90 & 180:"
  168.     put it into fld myangle
  169.   end if
  170. end mousedown
  171.  
  172.  
  173.  
  174. -- part 4 (button)
  175. -- low flags: 00
  176. -- high flags: C002
  177. -- rect: left=434 top=80 right=100 bottom=512
  178. -- title width / last selected line: 0
  179. -- icon id / first selected line: 0 / 0
  180. -- text alignment: 1
  181. -- font id: 3
  182. -- text size: 12
  183. -- style flags: 256
  184. -- line height: 16
  185. -- part name: Increment
  186. ----- HyperTalk script -----
  187. on mousedown
  188.   put PopUpMenu("1;2;3;4;5;6;7;8;9;10;11;12,Other‚Ķ", 0, the mouseV , the mouseH - 20) into which
  189.   if which is 0 then exit mousedown
  190.   if which is 13 then
  191.     ask "Please enter increment:"
  192.     put it into fld myincrement
  193.   else
  194.     put which into fld myincrement
  195.   end if
  196. end mousedown
  197.  
  198.  
  199.  
  200. -- part 5 (button)
  201. -- low flags: 00
  202. -- high flags: C002
  203. -- rect: left=434 top=131 right=150 bottom=512
  204. -- title width / last selected line: 0
  205. -- icon id / first selected line: 0 / 0
  206. -- text alignment: 1
  207. -- font id: 3
  208. -- text size: 12
  209. -- style flags: 256
  210. -- line height: 16
  211. -- part name: Line Width
  212. ----- HyperTalk script -----
  213. on mousedown
  214.   put PopUpMenu("1;2;3;4;5;6;7;8;Other‚Ķ", 0, the mouseV , the mouseH - 20) into which
  215.   if which is 0 then exit mousedown
  216.   if which is 9 then
  217.     ask "Please enter line width [1 to 8]:"
  218.     put it into fld myWidth
  219.   else
  220.     put which into fld myWidth
  221.   end if
  222. end mousedown
  223.  
  224.  
  225. -- part 6 (button)
  226. -- low flags: 00
  227. -- high flags: C002
  228. -- rect: left=434 top=231 right=251 bottom=512
  229. -- title width / last selected line: 0
  230. -- icon id / first selected line: 0 / 0
  231. -- text alignment: 1
  232. -- font id: 3
  233. -- text size: 12
  234. -- style flags: 256
  235. -- line height: 16
  236. -- part name: Last Line
  237. ----- HyperTalk script -----
  238. on mousedown
  239.   put PopUpMenu("150;200;250;300;350;400;450;550;650;Other‚Ķ", 0, the mouseV , the mouseH - 20) into which
  240.   if which is 0 then exit mousedown
  241.   if which  is 1 then
  242.     put "150" into fld myendL
  243.   else if which is 2 then
  244.     put "200" into fld myendL
  245.   else if which is 3 then
  246.     put "250" into fld myendL
  247.   else if which is 4 then
  248.     put "300" into fld myendL
  249.   else if which is 5 then
  250.     put "350" into fld myendL
  251.   else if which is 6 then
  252.     put "400" into fld myendL
  253.   else if which is 7 then
  254.     put "450" into fld myendL
  255.   else if which is 8 then
  256.     put "550" into fld myendL
  257.   else if which is 9 then
  258.     put "650" into fld myendL
  259.   else if which is 10 then
  260.     ask "Please enter length of longest line:"
  261.     put it into fld myendL
  262.   end if
  263. end mousedown
  264.  
  265.  
  266.  
  267. -- part 7 (button)
  268. -- low flags: 00
  269. -- high flags: C002
  270. -- rect: left=434 top=180 right=199 bottom=512
  271. -- title width / last selected line: 0
  272. -- icon id / first selected line: 0 / 0
  273. -- text alignment: 1
  274. -- font id: 3
  275. -- text size: 12
  276. -- style flags: 256
  277. -- line height: 16
  278. -- part name: First Line
  279. ----- HyperTalk script -----
  280. on mousedown
  281.   put PopUpMenu("1;2;3;4;5;6;7;8;9;10;20;30,Other‚Ķ", 0, the mouseV , the mouseH - 20) into which
  282.   if which is 0 then exit mousedown
  283.   if which  is 11 then
  284.     put "20" into fld mystartL
  285.   else if which is 12 then
  286.     put "30" into fld mystartL
  287.   else if which is 13 then
  288.     ask "Enter pixel length of first line:"
  289.     put it into fld mystartL
  290.   else
  291.     put which into fld mystartL
  292.   end if
  293. end mousedown
  294.  
  295.  
  296.  
  297.  
  298. -- part 8 (field)
  299. -- low flags: 00
  300. -- high flags: 0002
  301. -- rect: left=434 top=100 right=120 bottom=512
  302. -- title width / last selected line: 0
  303. -- icon id / first selected line: 0 / 0
  304. -- text alignment: 1
  305. -- font id: 3
  306. -- text size: 14
  307. -- style flags: 256
  308. -- line height: 18
  309. -- part name: myincrement
  310.  
  311.  
  312. -- part 9 (field)
  313. -- low flags: 00
  314. -- high flags: 0002
  315. -- rect: left=434 top=150 right=170 bottom=512
  316. -- title width / last selected line: 0
  317. -- icon id / first selected line: 0 / 0
  318. -- text alignment: 1
  319. -- font id: 3
  320. -- text size: 14
  321. -- style flags: 256
  322. -- line height: 18
  323. -- part name: myWidth
  324.  
  325.  
  326. -- part 10 (field)
  327. -- low flags: 00
  328. -- high flags: 0002
  329. -- rect: left=434 top=199 right=218 bottom=512
  330. -- title width / last selected line: 0
  331. -- icon id / first selected line: 0 / 0
  332. -- text alignment: 1
  333. -- font id: 3
  334. -- text size: 14
  335. -- style flags: 256
  336. -- line height: 18
  337. -- part name: mystartL
  338.  
  339.  
  340. -- part 11 (field)
  341. -- low flags: 00
  342. -- high flags: 0002
  343. -- rect: left=434 top=251 right=270 bottom=512
  344. -- title width / last selected line: 0
  345. -- icon id / first selected line: 0 / 0
  346. -- text alignment: 1
  347. -- font id: 3
  348. -- text size: 14
  349. -- style flags: 256
  350. -- line height: 18
  351. -- part name: myEndL
  352.  
  353.  
  354. -- part 12 (button)
  355. -- low flags: 00
  356. -- high flags: 8003
  357. -- rect: left=437 top=277 right=310 bottom=509
  358. -- title width / last selected line: 0
  359. -- icon id / first selected line: 0 / 0
  360. -- text alignment: 1
  361. -- font id: 3
  362. -- text size: 18
  363. -- style flags: 256
  364. -- line height: 24
  365. -- part name: SPIRO!
  366. ----- HyperTalk script -----
  367. on mouseUp
  368.   set the hilite of me to true
  369.   spiro
  370.   set the hilite of me to false
  371. end mouseUp
  372.  
  373.  
  374.  
  375. -- part 13 (button)
  376. -- low flags: 00
  377. -- high flags: 8003
  378. -- rect: left=437 top=318 right=338 bottom=509
  379. -- title width / last selected line: 0
  380. -- icon id / first selected line: 0 / 0
  381. -- text alignment: 1
  382. -- font id: 0
  383. -- text size: 12
  384. -- style flags: 0
  385. -- line height: 16
  386. -- part name: Clear All
  387. ----- HyperTalk script -----
  388. on mouseUp
  389.   set the hilite of me to true
  390.   if the commandkey is down then
  391.     choose select tool
  392.     domenu "select all"
  393.     domenu "invert"
  394.     drag from 434,1 to 512,342
  395.     type numtochar(8)
  396.     choose browse tool
  397.   else
  398.  
  399.     choose select tool
  400.     domenu "select all"
  401.     type numtochar(8)
  402.   end if
  403.   set the hilite of me to false
  404.  
  405.   choose browse tool
  406. end mouseUp
  407.  
  408.